﻿using System;
using System.Collections;
using System.Text;
using System.Data;
using FS.Business;
using Microsoft.Reporting.WebForms;

namespace FS.Web.BLL.Query
{
    public partial class Report_Customer : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                this.bind(null);
            }
        }

        protected void lbtSearch_Click(object sender, EventArgs e)
        {
            StringBuilder sb = new StringBuilder();

            Hashtable ht = new Hashtable();
            ht.Add("cusname", this.cusname.Value.Trim());
            ht.Add("cuscardno", this.cuscardno.Value.Trim());
            ht.Add("cusphone", this.cusphone.Value.Trim());

            DataTable dt = DataFactory.Run().GetDataTableProc("usp_Report_CustomerInfo", ht);           
            this.bind(dt);
        }

        private void bind(DataTable dt)
        {
           
            if (dt == null)
            {
                dt = new ds_report().usp_Report_CustomerInfo;
                dt.NewRow();
            }
            
            ReportViewer1.LocalReport.ReportPath = MapPath("/BLL/Query/Report/Report_CustomerInfo.rdlc");           
            ReportDataSource reportDataSource1 = new ReportDataSource("DataSet1", dt);            
            ReportViewer1.LocalReport.DataSources.Clear();
            ReportViewer1.LocalReport.DataSources.Add(reportDataSource1);
            if (dt!= null)
            {
                ReportViewer1.LocalReport.Refresh();
            }
        }
    }
}